<template>
	<view class="container">
		<!-- 我的订单 -->
		<u-navbar leftIcon="arrow-left" @leftClick="back" title="我的订单" bg-color="#00000000" titleStyle="color:#fff"
			leftIconColor="#fff" placeholder></u-navbar>

		<view class="content">
			<!-- 背景 -->
			<view class="top-bg"></view>

			<view class="main">
				<!-- tab头部 -->
				<u-tabs :list="list1" :current="current" @change="changeTab" :scrollable="false"
					activeStyle="font-size: 30rpx;color:#fff" inactiveStyle="font-size: 30rpx;color:#fff">
				</u-tabs>
				<!-- tab内容 -->
				<view class="tab-content">
					<!-- 全部 -->
					<block v-if="tabs[0]">
						<view class="list">
							<view class="top">
								<text class="title">订单编号:242545265555</text>
								<image src="../../../static/images/my-up.png" @click="toDetails(3)"></image>
							</view>
							<view class="line"></view>
							<view>
								<text class="name">服务项目：车辆保养</text>
							</view>
							<view>
								<view class="name">服务门店：大宝车辆维修店<image src="../../../static/images/myorder-plane.png">
									</image>
								</view>
								<text class="state">待评价</text>
							</view>
							<view>
								<text class="name">下单时间：2023-03-12 12:09</text>
							</view>
							<view class="line"></view>
							<view class="bottom">
								<view class="name" style="margin: 0;">实付：<text>230.56元</text></view>
								<view class="btn">
									<view class="btn-size evaluate" style="margin-right: 20rpx;" @click="toEvaluate">
										立即评价</view>
									<view class="btn-size onemore">再来一单</view>
								</view>
							</view>
						</view>

						<view class="list">
							<view class="top">
								<text class="title">订单编号:242545265555</text>
								<image src="../../../static/images/my-up.png" @click="toDetails(5)"></image>
							</view>
							<view class="line"></view>
							<view>
								<text class="name">服务项目：车辆保养</text>
							</view>
							<view>
								<view class="name">服务门店：大宝车辆维修店<image src="../../../static/images/myorder-plane.png">
									</image>
								</view>
								<text class="state" style="color: grey;">已取消</text>
							</view>
							<view>
								<text class="name">下单时间：2023-03-12 12:09</text>
							</view>
							<view class="line"></view>
							<view class="bottom">
								<view class="name" style="margin: 0;">应付：<text>230.56元</text></view>
								<view class="btn">
									<view class="btn-size onemore">再来一单</view>
								</view>
							</view>
						</view>

						<view class="list">
							<view class="top">
								<text class="title">订单编号:242545265555</text>
								<image src="../../../static/images/my-up.png" @click="toDetails(6)"></image>
							</view>
							<view class="line"></view>
							<view>
								<text class="name">服务项目：车辆保养</text>
							</view>
							<view>
								<view class="name">服务门店：大宝车辆维修店<image src="../../../static/images/myorder-plane.png">
									</image>
								</view>
								<text class="state" style="color: grey;">已退款</text>
							</view>
							<view>
								<text class="name">下单时间：2023-03-12 12:09</text>
							</view>
							<view class="line"></view>
							<view class="bottom">
								<view class="name" style="margin: 0;">实付：<text>230.56元</text></view>
								<view class="btn">
									<view class="btn-size onemore">再来一单</view>
								</view>
							</view>
						</view>

						<view class="list">
							<view class="top">
								<text class="title">订单编号:242545265555</text>
								<image src="../../../static/images/my-up.png" @click="toDetails(4)"></image>
							</view>
							<view class="line"></view>
							<view>
								<text class="name">服务项目：车辆保养</text>
							</view>
							<view>
								<view class="name">服务门店：大宝车辆维修店<image src="../../../static/images/myorder-plane.png">
									</image>
								</view>
								<text class="state">已完成</text>
							</view>
							<view>
								<text class="name">下单时间：2023-03-12 12:09</text>
							</view>
							<view class="line"></view>
							<view class="bottom">
								<view class="name" style="margin: 0;">实付：<text>230.56元</text></view>
								<view class="btn">
									<view class="btn-size onemore">再来一单</view>
								</view>
							</view>
						</view>
					</block>

					<!-- 待支付 -->
					<block v-if="tabs[1]">
						<view class="list">
							<view class="top">
								<text class="title">订单编号:242545265555</text>
								<image src="../../../static/images/my-up.png" @click="toDetails"></image>
							</view>
							<view class="line"></view>
							<view>
								<text class="name">服务项目：车辆保养</text>
							</view>
							<view>
								<view class="name">服务门店：大宝车辆维修店<image src="../../../static/images/myorder-plane.png">
									</image>
								</view>
								<text class="state">待支付</text>
							</view>
							<view>
								<text class="name">下单时间：2023-03-12 12:09</text>
							</view>
							<view class="line"></view>
							<view class="bottom">
								<view class="name" style="margin: 0;">实付：<text style="color: red;">230.56元</text></view>
								<view class="btn">
									<view class="btn-size evaluate" style="margin-right: 20rpx;" @click="click">取消订单
									</view>
									<view class="btn-size onemore">立即支付</view>
								</view>
							</view>
						</view>

						<view class="list">
							<view class="top">
								<text class="title">订单编号:242545265555</text>
								<image src="../../../static/images/my-up.png" @click="toDetails"></image>
							</view>
							<view class="line"></view>
							<view>
								<text class="name">服务项目：车辆保养</text>
							</view>
							<view>
								<view class="name">服务门店：大宝车辆维修店<image src="../../../static/images/myorder-plane.png">
									</image>
								</view>
								<text class="state">待支付</text>
							</view>
							<view>
								<text class="name">下单时间：2023-03-12 12:09</text>
							</view>
							<view class="line"></view>
							<view class="bottom">
								<view class="name" style="margin: 0;">应付：<text style="color: red;">230.56元</text></view>
								<view class="btn">
									<view class="btn-size evaluate" style="margin-right: 20rpx;" @click="click">取消订单
									</view>
									<view class="btn-size onemore">立即支付</view>
								</view>
							</view>
						</view>
					</block>

					<!-- 待使用 -->
					<block v-if="tabs[2]">
						<view class="list">
							<view class="top">
								<text class="title">订单编号:242545265555</text>
								<image src="../../../static/images/my-up.png" @click="toDetails"></image>
							</view>
							<view class="line"></view>
							<view>
								<text class="name">服务项目：车辆保养</text>
							</view>
							<view>
								<view class="name">服务门店：大宝车辆维修店<image src="../../../static/images/myorder-plane.png">
									</image>
								</view>
								<text class="state">待使用</text>
							</view>
							<view>
								<text class="name">下单时间：2023-03-12 12:09</text>
							</view>
							<view class="line"></view>
							<view class="bottom">
								<view class="name" style="margin: 0;">实付：<text style="color: red;">230.56元</text></view>
								<view class="btn">
									<view class="btn-size evaluate" style="margin-right: 20rpx;" @click="click">申请退款
									</view>
									<view class="btn-size onemore" @click="pay">扫码结算</view>
								</view>
							</view>
						</view>

						<view class="list">
							<view class="top">
								<text class="title">订单编号:242545265555</text>
								<image src="../../../static/images/my-up.png" @click="toDetails"></image>
							</view>
							<view class="line"></view>
							<view>
								<text class="name">服务项目：车辆保养</text>
							</view>
							<view>
								<view class="name">服务门店：大宝车辆维修店<image src="../../../static/images/myorder-plane.png">
									</image>
								</view>
								<text class="state">待使用</text>
							</view>
							<view>
								<text class="name">下单时间：2023-03-12 12:09</text>
							</view>
							<view class="line"></view>
							<view class="bottom">
								<view class="name" style="margin: 0;">应付：<text style="color: red;">230.56元</text></view>
								<view class="btn">
									<view class="btn-size evaluate" style="margin-right: 20rpx;" @click="click">申请退款
									</view>
									<view class="btn-size onemore" @click="pay">扫码结算</view>
								</view>
							</view>
						</view>

						<view class="list">
							<view class="top">
								<text class="title">订单编号:242545265555</text>
								<image src="../../../static/images/my-up.png" @click="toDetails"></image>
							</view>
							<view class="line"></view>
							<view>
								<text class="name">服务项目：车辆保养</text>
							</view>
							<view>
								<view class="name">服务门店：大宝车辆维修店<image src="../../../static/images/myorder-plane.png">
									</image>
								</view>
								<text class="state">待使用</text>
							</view>
							<view>
								<text class="name">下单时间：2023-03-12 12:09</text>
							</view>
							<view class="line"></view>
							<view class="bottom">
								<view class="name" style="margin: 0;">应付：<text style="color: red;">230.56元</text></view>
								<view class="btn">
									<view class="btn-size evaluate" style="margin-right: 20rpx;" @click="click">申请退款
									</view>
									<view class="btn-size onemore" @click="pay">扫码结算</view>
								</view>
							</view>
						</view>
					</block>


					<!-- 待评价 -->
					<block v-if="tabs[3]">
						<view class="list">
							<view class="top">
								<text class="title">订单编号:242545265555</text>
								<image src="../../../static/images/my-up.png" @click="toDetails"></image>
							</view>
							<view class="line"></view>
							<view>
								<text class="name">服务项目：车辆保养</text>
							</view>
							<view>
								<view class="name">服务门店：大宝车辆维修店<image src="../../../static/images/myorder-plane.png">
									</image>
								</view>
								<text class="state">待评价</text>
							</view>
							<view>
								<text class="name">下单时间：2023-03-12 12:09</text>
							</view>
							<view class="line"></view>
							<view class="bottom">
								<view class="name" style="margin: 0;">实付：<text>230.56元</text></view>
								<view class="btn">
									<view class="btn-size evaluate" style="margin-right: 20rpx;" @click="toEvaluate">
										立即评价</view>
									<view class="btn-size onemore">再来一单</view>
								</view>
							</view>
						</view>

						<view class="list">
							<view class="top">
								<text class="title">订单编号:242545265555</text>
								<image src="../../../static/images/my-up.png" @click="toDetails"></image>
							</view>
							<view class="line"></view>
							<view>
								<text class="name">服务项目：车辆保养</text>
							</view>
							<view>
								<view class="name">服务门店：大宝车辆维修店<image src="../../../static/images/myorder-plane.png">
									</image>
								</view>
								<text class="state">待评价</text>
							</view>
							<view>
								<text class="name">下单时间：2023-03-12 12:09</text>
							</view>
							<view class="line"></view>
							<view class="bottom">
								<view class="name" style="margin: 0;">应付：<text>230.56元</text></view>
								<view class="btn">
									<view class="btn-size evaluate" style="margin-right: 20rpx;" @click="toEvaluate">
										立即评价</view>
									<view class="btn-size onemore">再来一单</view>
								</view>
							</view>
						</view>

						<view class="list">
							<view class="top">
								<text class="title">订单编号:242545265555</text>
								<image src="../../../static/images/my-up.png" @click="toDetails"></image>
							</view>
							<view class="line"></view>
							<view>
								<text class="name">服务项目：车辆保养</text>
							</view>
							<view>
								<view class="name">服务门店：大宝车辆维修店<image src="../../../static/images/myorder-plane.png">
									</image>
								</view>
								<text class="state">待评价</text>
							</view>
							<view>
								<text class="name">下单时间：2023-03-12 12:09</text>
							</view>
							<view class="line"></view>
							<view class="bottom">
								<view class="name" style="margin: 0;">应付：<text>230.56元</text></view>
								<view class="btn">
									<view class="btn-size evaluate" style="margin-right: 20rpx;" @click="toEvaluate">
										立即评价</view>
									<view class="btn-size onemore">再来一单</view>
								</view>
							</view>
						</view>
					</block>
				</view>
			</view>
			<!-- 弹出框(取消订单、申请退款) -->
			<u-modal :show="show" :content='content' :showCancelButton="true" @confirm="confirm"
				@cancel="cancel"></u-modal>
			<!-- 弹出框(扫码结算) -->
			<u-popup :show="showqr" @close="close" mode="center" round="5">
				<view class="popup">
					<view class="title">使用凭证</view>
					<view class="close" @click="close">+</view>
					<view class="qr-code">
						<uqrcode ref="uqrcode" canvas-id="qrcode" value="https://uqrcode.cn/doc" :options="{  }"
							size="80"></uqrcode>
					</view>
				</view>
			</u-popup>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				//tab滑块样式
				barStyle: {
					backgroundcolor: '#fff'
				},
				tabs: [true, false, false, false],
				current: 0,
				list1: [{
					name: '全部',
				}, {
					name: '待支付',
				}, {
					name: '待使用'
				}, {
					name: '待评价'
				}, ],
				type: '',
				// 弹窗1
				show: false,
				content: '',
				// 弹窗2
				showqr: false,
			};
		},
		onLoad(option) {
			// console.log(option)
			//根据传过来的参数显示相应tab
			this.current = option.type;
			this.tabs.forEach((value, index, arr) => {
				if (this.current == index) {
					arr[index] = true;
				} else {
					arr[index] = false;
				}
			})
		},
		methods: {
			// 返回我的页面
			back() {
				uni.switchTab({
					url: '../My'
				});
			},
			// tab切换
			changeTab(item) {
				// console.log('item', item);
				//更新current
				this.current = item.index;
				this.tabs.forEach((value, index, arr) => {
					if (this.current == index) {
						arr[index] = true;
					} else {
						arr[index] = false;
					}
				})
			},
			//跳转详情页
			toDetails(type) {
				// console.log(111);
				//全部跳转详情
				if (this.tabs[0]) {
					uni.navigateTo({
						url: './OrderDetail?type=' + type
					})
				} else { //其他跳转详情
					this.tabs.forEach((value, index, arr) => {
						if (value == true) {
							this.type = index; //哪个tab显示就传递相应参数
						}
					});
					uni.navigateTo({
						url: './OrderDetail?type=' + this.type //跳转传参
					});
				}
			},
			//跳转评价
			toEvaluate() {
				uni.navigateTo({
					url: './Evaluate'
				})
			},
			// 弹窗1
			click() {
				this.show = true;
				if (this.tabs[1]) {
					this.content = '确定要取消该订单吗？';
				} else {
					this.content = '退款后将原路返回到支付账户,请确认是否退款!';
				}
			},
			confirm() {
				this.show = false;
			},
			cancel() {
				this.show = false;
			},
			// 弹窗2
			pay() {
				this.showqr = true;
			},
			close() {
				this.showqr = false;
			}
		}
	}
</script>

<style lang="scss">
	.content {
		position: absolute;
		top: 0;

		.top-bg {
			width: 750rpx;
			height: 400rpx;
			// background-image: url('http://www.img.ttblog.cn/car/header-bg.png');
			background-color: #3384FC;
			background-size: cover;
		}

		.main {
			transform: translateY(-170rpx);
			margin-top: -70rpx;
			padding: 0 20rpx;

			/deep/ .u-tabs__wrapper__nav__line {
				background-color: #fff !important;
				width: 100rpx !important;
				margin-left: -30rpx;
				margin-bottom: 6rpx;
			}

			.list {
				padding: 30rpx 30rpx;
				background-color: #fff;
				border-radius: 20rpx;
				margin-bottom: 30rpx;

				.top {
					display: flex;
					flex-direction: row;
					justify-content: space-between;
					align-items: center;

					.title {
						font-size: 27rpx;
						font-weight: bold;
					}

					image {
						width: 15rpx;
						height: 25rpx;
					}

				}

				.line {
					border-bottom: 7rpx solid #f7f7f7;
					padding-top: 18rpx;
				}

				.name {
					font-size: 24rpx;
					margin-top: 18rpx;
					display: inline-block;

					image {
						width: 20rpx;
						height: 20rpx;
						margin-left: 15rpx;
					}
				}

				.state {
					color: #053FFF;
					font-size: 22rpx;
					margin-left: 200rpx;
				}

				.bottom {
					display: flex;
					flex-direction: row;
					justify-content: space-between;
					align-items: center;
					margin-top: 10rpx;

					.btn {
						font-size: 24rpx;
						display: flex;
						flex-direction: row;
						color: #fff;

						.btn-size {
							width: 140rpx;
							height: 50rpx;
							line-height: 50rpx;
							text-align: center;
							border-radius: 10rpx;
						}

						.evaluate {
							background-color: #D9D9D9
						}

						.onemore {
							background-color: #1E72F0
						}
					}
				}
			}

			.placeholder {
				height: 15.33vw;
			}

			/deep/ .u-button {
				width: 80%;
				background-color: #D9D9D9;
				color: #fff;
			}
		}

		.popup {
			width: 450rpx;
			height: 300rpx;
			text-align: center;
			padding: 20rpx;
			box-sizing: border-box;
			
			.title{
				font-size: 26rpx;
				font-weight: bold;
			}

			.close {
				font-weight: bold;
				font-size: 50rpx;
				position: absolute;
				top: 0;
				right: 20rpx;
				transform: rotate(45deg);
			}

			.qr-code {
				margin: 20rpx auto 0;
				display: block;
				width: 160rpx;
				height: 160rpx;
			}
		}
	}
</style>